home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / dvips / RCS / special.lpro,v < prev    next >
Encoding:
Text File  |  1990-09-24  |  7.9 KB  |  326 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @@;
  7.  
  8.  
  9. 1.1
  10. date     90.02.27.10.59.28;  author douglis;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @as distributed... file for tex ps prolog
  17. @
  18.  
  19.  
  20.  
  21. 1.1
  22. log
  23. @Initial revision
  24. @
  25. text
  26. @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  27. %%     header for the \special command
  28. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  29. %   The structure of the PostScript produced by dvips for \special is:
  30. %         @@beginspecial
  31. %           - any number of @@hsize, @@hoffset, @@hscale, etc., commands
  32. %         @@setspecial
  33. %           - the user's file of PostScript commands
  34. %         @@endspecial
  35.  
  36. TeXDict begin
  37. /SDict 200 dict def
  38. SDict begin
  39.  
  40. /@@SpecialDefaults
  41.   { /hs 612 def
  42.     /vs 792 def
  43.     /ho 0 def
  44.     /vo 0 def
  45.     /hsc 1 def
  46.     /vsc 1 def
  47.     /ang 0 def
  48.     /CLIP false def
  49.     /BBcalc false def
  50.   } bdf
  51.  
  52. %
  53. %   The following definition sets up the units that hscale/vscale are in.
  54. %   For certain sites this might require change, but it is
  55. %   recommended instead that any macro packages that require
  56. %   hscale/vscale set the units appropriately via
  57. %
  58. %   \special{! /@@scaleunit 1 def }
  59. %
  60. %   if global, or
  61. %
  62. %   \special{" /@@scaleunit 1 def }
  63. %
  64. %   before each instance if multiple macro packages with
  65. %   different requirements are being used.
  66. %
  67. /@@scaleunit 100 def
  68. %       s @@hscale  -    set scale factor
  69. /@@hscale {@@scaleunit div /hsc exch def} bdf
  70. /@@vscale {@@scaleunit div /vsc exch def} bdf
  71.  
  72. %       d @@hsize   -    specify a horizontal clipping dimension
  73. /@@hsize {/hs exch def /CLIP true def} bdf
  74. /@@vsize {/vs exch def /CLIP true def} bdf
  75.  
  76. %       d @@hoffset -    specify a shift for the figure
  77. /@@hoffset {/ho exch def} bdf
  78. /@@voffset {/vo exch def} bdf
  79.  
  80. %       a @@angle   -    set rotation angle
  81. /@@angle {/ang exch def} bdf
  82.  
  83. %
  84. %   Here we handle bounding box calculations, if necessary.
  85. %
  86. /@@rwi { 10 div /rwi exch def } bdf % rwi will be real width after scaling
  87. /@@llx { /llx exch def } bdf
  88. /@@lly { /lly exch def } bdf
  89. /@@urx { /urx exch def } bdf
  90. /@@ury { /ury exch def /BBcalc true def } bdf
  91.  
  92. end % of SDict
  93.  
  94. /@@MacSetUp
  95.   { userdict /md known  % if md is defined
  96.       { userdict /md get type /dicttype eq      % and if it is a dictionary
  97.     {
  98.     md begin                             % then redefine some stuff
  99.     /letter {} def
  100.     /note {} def
  101.     /legal {} def
  102.     /od{txpose
  103.         1 0 mtx defaultmatrix dtransform exch atan/pa exch def
  104.         newpath clippath mark
  105.         {transform{itransform moveto}}
  106.         {transform{itransform lineto}}
  107.         { 6 -2 roll transform
  108.           6 -2 roll transform
  109.           6 -2 roll transform
  110.           { itransform 6 2 roll
  111.         itransform 6 2 roll
  112.         itransform 6 2 roll
  113.         curveto
  114.           }
  115.         }
  116.         {{closepath}}
  117.         pathforall newpath counttomark array astore /gc xdf
  118.         pop ct 39 0 put
  119.         10 fz 0 fs 2 F/|______Courier fnt invertflag{PaintBlack}if
  120.     }def
  121.     /txpose{
  122.         pxs pys scale ppr aload pop
  123.         por {
  124.         noflips {
  125.             pop exch neg exch translate pop 1 -1 scale
  126.         }if
  127.         xflip yflip and {
  128.             pop exch neg exch translate 180 rotate 1 -1 scale
  129.             ppr 3 get ppr 1 get neg sub neg ppr 2 get
  130.             ppr 0 get neg sub neg translate
  131.         }if 
  132.         xflip yflip not and {
  133.             pop exch neg exch translate pop 180 rotate
  134.             ppr 3 get ppr 1 get neg sub neg 0 translate
  135.         }if
  136.         yflip xflip not and {
  137.             ppr 1 get neg ppr 0 get neg translate
  138.         }if
  139.         }
  140.         {
  141.         noflips {
  142.             translate pop pop 270 rotate 1 -1 scale
  143.         }if
  144.         xflip yflip and {
  145.             translate pop pop 90 rotate 1 -1 scale
  146.             ppr 3 get ppr 1 get neg sub neg ppr 2 get
  147.             ppr 0 get neg sub neg translate
  148.         }if
  149.         xflip yflip not and {
  150.             translate pop pop 90 rotate ppr 3 get
  151.             ppr 1 get neg sub neg 0 translate
  152.         }if
  153.         yflip xflip not and {
  154.             translate pop pop 270 rotate ppr 2 get
  155.             ppr 0 get neg sub neg 0 exch translate
  156.         }if
  157.         }ifelse
  158.         scaleby96 {
  159.         ppr aload pop 4 -1 roll add 2 div 3 1 roll add 2 div 2 copy
  160.         translate .96 dup scale neg exch neg exch translate
  161.         }if
  162.     }def
  163.     /cp {pop pop showpage pm restore}def
  164.         end
  165.       }if
  166.     } if    
  167.   } def
  168.  
  169. %
  170. %   We need the psfig macros.
  171. %
  172. % All software, documentation, and related files in this distribution of
  173. % psfig/tex are Copyright (c) 1987 Trevor J. Darrell
  174. %
  175. % Permission is granted for use and non-profit distribution of psfig/tex 
  176. % providing that this notice be clearly maintained, but the right to
  177. % distribute any portion of psfig/tex for profit or as part of any commercial
  178. % product is specifically reserved for the author.
  179. %
  180. %
  181. % psfigTeX PostScript Prolog
  182. % $Header: tex.ps,v 1.15 88/01/21 23:44:40 van Exp $
  183. %
  184. /psf$TeXscale { 65536 div } def
  185.  
  186. %  x y bb-llx bb-lly bb-urx bb-ury startFig -
  187. /startTexFig {
  188.     /psf$SavedState save def
  189.     userdict maxlength dict begin
  190.  
  191.         Resolution 72 div dup neg scale
  192.         currentpoint translate    %set the current point as the user's origin
  193.  
  194.     /psf$ury exch psf$TeXscale def
  195.     /psf$urx exch psf$TeXscale def
  196.     /psf$lly exch psf$TeXscale def
  197.     /psf$llx exch psf$TeXscale def
  198.     /psf$y exch psf$TeXscale def
  199.     /psf$x exch psf$TeXscale def
  200.     
  201.     currentpoint /psf$cy exch def /psf$cx exch def
  202.  
  203.     /psf$sx psf$x psf$urx psf$llx sub div def     % scaling for x
  204.     /psf$sy psf$y psf$ury psf$lly sub div def    % scaling for y
  205.  
  206.     psf$sx psf$sy scale            % scale by (sx,sy)
  207.  
  208.     psf$cx psf$sx div psf$llx sub
  209.     psf$cy psf$sy div psf$ury sub translate
  210.     
  211.     /showpage {
  212.     } def
  213.     /erasepage {
  214.     } def
  215.     /copypage {
  216.     } def
  217.     @@MacSetUp
  218. } def
  219.  
  220. % llx lly urx ury doclip -    (args in figure coordinates)
  221. /doclip {
  222.         psf$llx psf$lly psf$urx psf$ury
  223.     currentpoint 6 2 roll
  224.     newpath 4 copy
  225.     4 2 roll moveto
  226.     6 -1 roll exch lineto
  227.     exch lineto
  228.     exch lineto
  229.     closepath clip
  230.     newpath
  231.     moveto
  232. } def
  233. % - endTexFig -
  234. /endTexFig { end psf$SavedState restore } def
  235.  
  236. % this will be invoked as the result of a \special command (for the
  237. % inclusion of PostScript graphics).  The basic idea is to change all
  238. % scaling and graphics back to defaults, but to shift the origin
  239. % to the current position on the page.
  240.  
  241. /@@beginspecial          % - @@beginspecial -     -- enter special mode
  242.   { SDict begin
  243.     /SpecialSave save def
  244.     gsave
  245.     Resolution 72 div dup neg scale
  246.     currentpoint translate    %set the current point as the user's origin
  247.     @@SpecialDefaults    % setup default offsets, scales, sizes, and angle
  248.   } bdf
  249.  
  250. /@@setspecial    % to setup user specified offsets, scales, sizes (for clipping)
  251.   {
  252.     CLIP
  253.       { newpath 0 0 moveto hs 0 rlineto 0 vs rlineto hs neg 0 rlineto 
  254.         closepath clip }
  255.       { initclip }
  256.     ifelse
  257.     ho vo translate
  258.     hsc vsc scale
  259.     ang rotate
  260.     BBcalc
  261.       { rwi urx llx sub div dup scale
  262.         llx neg lly neg translate }
  263.     if
  264.     /showpage {} def
  265.     newpath
  266.   } bdf
  267.  
  268. /@@endspecial            % - @@endspecial -       -- leave special mode
  269.   { grestore clear SpecialSave restore
  270.     end
  271.   } bdf
  272. /@@defspecial
  273.   {
  274.     SDict begin
  275.   } bdf
  276. /@@fedspecial
  277.   {
  278.     end
  279.   } bdf
  280.  
  281. %%% macros for tpic
  282. /li             % x y li -              -- draw line to
  283.   { lineto
  284.   } bdf
  285.  
  286. /rl             % dx dy rl -            -- draw relative line
  287.   { rlineto
  288.   } bdf
  289.  
  290. /rc             % x0 y0 x1 y1 y2 y2 rc  -- draw bezier curve
  291.   { rcurveto
  292.   } bdf
  293.  
  294. /np        % np -            -- start a new path and save currenpoint
  295.   { /SaveX currentpoint /SaveY exch def def   % remember current point
  296.     newpath
  297.   } bdf
  298.  
  299. /st             % st -                  -- draw the last path and restore currentpoint
  300.   { stroke
  301.     SaveX SaveY moveto                  % restore the current point
  302.   } bdf
  303.  
  304. /fil             % fil                    -- fill the last path and restore currentpoint
  305.   { fill
  306.     SaveX SaveY moveto                  % restore the current point
  307.   } bdf
  308.  
  309. /ellipse        % xc yc xrad yrad startAngle endAngle ellipse
  310.     {
  311.         /endangle exch def
  312.         /startangle exch def
  313.         /yrad exch def
  314.         /xrad exch def
  315.  
  316.         /savematrix matrix currentmatrix def
  317.  
  318.         translate
  319.         xrad yrad scale
  320.         0 0 1 startangle endangle arc
  321.         savematrix setmatrix
  322.     } bdf
  323. %%% end of macros for tpic
  324. end                     % revert to previous dictionary
  325. @
  326.